﻿@model IQueryable<UMS.Core.Data.Models.App.Department>
@{
    ViewBag.Title = "Departments";
    Layout = "~/Areas/Admin/Views/Shared/_Config.cshtml";
    var e = ViewData["Enable"] is bool && (bool)ViewData["Enable"];
    var grid = new WebGrid(Model, defaultSort: "Name");
}
@section Head
{
    @Styles.Render("~/bundles/css/jquery")
}
<div class="box">
    <div class="head">
        Departments
    </div>
    <p>
        Departments allows you to specify a list of values to allow users to select from
        when making changes to their information or others. You can either enable or disable
        the pre-defined list of departments as well as edit the pre-defined list of departments
        from this page.
    </p>
    <h3>
        Enable/Disable List
    </h3>
    @using (Html.BeginForm("Enable", "Departments", FormMethod.Post))
    {
        <div>
            Enable List?
        </div>
        @Html.CheckBox("Enabled", e)
        <br />
        <input type="submit" value="Save Changes" />
    }
    <hr />
    <h3>
        Add New Department
    </h3>
    @using (Html.BeginForm("Add", "Departments", FormMethod.Post, new { id = "AddDepartment" }))
    {
        <div>
            Department Name
        </div>
        <input data-val="true" data-val-length="The name of the department cannot be longer than 50 characters."
            data-val-length-max="50" data-val-required="You must specify a name for the department."
            id="Name" name="Name" type="text" value="" />
        <br />
        <input type="submit" value="Add Department" />
        
    }
    <hr />
    <h3>
        Available Departments
    </h3>
    @grid.GetHtml(tableStyle: "data", columns: grid.Columns(
        grid.Column(style: "icon clear-fix", format: @<text><a class="delete" href="/Admin/Departments/Delete/@item.DepartmentId">&nbsp;</a></text>),
        grid.Column("Name"),
        grid.Column("AddedOn", "Date Added (UTC)", format: @<text><abbr class="timeago" title="@String.Format("{0:s}", item.AddedOn)"></abbr></text>)
    ))
</div>
@section Script
{
    <script type="text/javascript">
        $(function () {
            $("#AddDepartment").makeValidationInline();
            $("abbr.timeago").timeago();
        });
    </script>
}
